﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfApp_MvvmPatten.Base;

namespace WpfApp_MvvmPatten.Model;

public class CalculateResoutModel:INotifyPropertyChanged
{

    public event PropertyChangedEventHandler? PropertyChanged;
    public CalculateResoutModel(ObservableCollection<CalculateResoutModel> datas)
    {
        //删除方式一，再model里面定义命令，通过引用传递Collection对象删除自己
        this.DelCommand = new MvvmCommand(param => 
        {
            datas.Remove(this);
        });
        this.UpdateCommand = new MvvmCommand(param =>
        {
            this.State = 2;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("State"));
        });
    }

    public string? ProgressStr { get; set; }

    private int _State;

    

    public int State
    {
        get { return _State; }
        set { _State = value; }
    }

    public MvvmCommand? DelCommand { get; set; }
    public MvvmCommand? UpdateCommand { get; set; }
}
